var app = getApp()
var config = require('../../utils/config.js')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    notice: Object,
    index: Number,
    imgs:Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    nickname: wx.getStorageSync("nickname"),
    headImg: wx.getStorageSync("headImg"),
  },

  /**
   * 组件的方法列表
   */
  methods: {
    detail() {
      if (this.data.notice.status == 1) {
        wx.navigateTo({
          url: '../detail/index?id=' + this.data.notice.noticeId,
        })
      }
    },
    del() {
      let token = wx.getStorageSync('token')
      let _this = this;
      wx.request({
        url: config.HOST + '/notice/delNotice',
        data: {
          token: token,
          noticeId: this.properties.notice.noticeId
        },
        success() {
          _this.triggerEvent('delNotice', _this.properties.index)
        }
      })
    },
    // 跳转到公告分类上去
    categoryList(event) {
      let cid = event.target.dataset.cid
      let cname = event.target.dataset.cname
      wx.navigateTo({
        url: '../category/index?cid=' + cid + '&cname=' + cname,
      })
    }
  },
  // 页面完成，初始化图片
  ready() {
    this.setData({
      nickname: wx.getStorageSync("nickname"),
      headImg: wx.getStorageSync("headImg"),
    })
  }
})